﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using Splash;
using System.Drawing;
using System.Resources;

namespace Carbon_Tracker
{
    static class Program
    {
        static SplashScreen splash;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            const String resourceName = "Splash.png";
            var InfoLabel = new Point(25, 92);
            var StatusLabel = new Point(28, 261);
            
            splash = SplashScreen.Current;
            splash.SetTransparentKey = Color.Fuchsia;
            var rs = GetResourceStream(resourceName);
            splash.SetBackgroundImage = new Bitmap(rs);
            splash.SetInfoLabel(InfoLabel, 499, 117);
            splash.SetStatusLabel(StatusLabel, 490, 17);
            //splash.TimerInterval = 5000;

            splash.ShowSplashScreen();
            splash.SetInfo = "";
            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.AssemblyLoad += asmLoadHandler;
            
            
            Application.Run(new frmMain());
        }
        private static System.IO.Stream GetResourceStream(String resource)
        {
            var ea = System.Reflection.Assembly.GetExecutingAssembly();
            
            foreach (String curResource in ea.GetManifestResourceNames())
            {
                if (curResource.EndsWith(resource))
                {
                    return ea.GetManifestResourceStream
                                (curResource);
                }
            }
            return ea.GetManifestResourceStream(resource); ;
        }

        static void asmLoadHandler(object sender, AssemblyLoadEventArgs args)
        {
            splash.SetStatus = "Loading Assembly: " +
                args.LoadedAssembly.GetName().Name + " ...";
        }
    }
}
